Completed
Push — master ( 734acd...e65e46 )
by Pieter Epeüs
13s queued 10s
created

f.diff   A

Complexity

Conditions 1

Size

Total Lines 1
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 1
rs 10
c 0
b 0
f 0
cc 1
1
class t{constructor(t,r){this.key=t,this.moveDirection="desc"===r?-1:1}order(t){return t.sort(this.compare.bind(this))}compare(t,r){let e=t[this.key],n=r[this.key];return"string"==typeof e&&(e=e.toUpperCase()),"string"==typeof n&&(n=n.toUpperCase()),e<n?-1*this.moveDirection:e>n?1*this.moveDirection:0}static create(r,e,n){return new t(e,n).order(r)}}function r(r,e,n){return t.create(r,e,n)}function e(t){return"object"!=typeof t||t.length<1?null:t.reduce((t,r)=>Math.min(t,r))}function n(t){return"object"!=typeof t||t.length<1?null:t.reduce((t,r)=>Math.max(t,r))}class i{constructor(t,r){this.find=t,this.operator=r||null}check(t){return Array.isArray(this.find)?this.checkOperators(t,this.find.indexOf(t)<0):this.checkOperators(t,String(t)!==String(this.find))}checkOperators(t,r){const i=n(this.find),s=e(this.find),h=null!==i,o=null!==s;return r&&("!="===this.operator||"<>"===this.operator)||!r&&!this.operator||(t>i&&h||t>this.find)&&">"===this.operator||(t>=i&&h||t>=this.find)&&">="===this.operator||(t<s&&o||t<this.find)&&"<"===this.operator||(t<=s&&o||t<=this.find)&&"<="===this.operator}static create(t,r,e,n){const s=new i(e,n);return t.filter(t=>{let e=t[r];return!!e&&(e=e.toString().split(","),e.some(s.check.bind(s)))})}}function s(t,r,e,n){return i.create(t,r,e,n)}function h(t,r){return t.map(t=>{const e={};return"object"==typeof r?(r.forEach(r=>{e[r]=t[r]}),e):t[r]})}function o(t,r,e){return t.filter(t=>e?r.reduce((r,e)=>e.indexOf(t)>=0?r+1:r,0)===r.length:r.indexOf(t)>=0)}class u{constructor(t,r,e){this.currentArray=t,this.otherArray=r,this.total=e}get differenceArray(){return this.currentArray.filter(t=>this.otherArray.indexOf(t)<0)}get differenceArrayB(){return this.total?this.otherArray.filter(t=>this.currentArray.indexOf(t)<0):[]}get compare(){return this.differenceArray.concat(this.differenceArrayB)}static create(t,r,e){return new u(t,r,e).compare}}function c(t,r,e){return u.create(t,r,e)}function a(t){return t.filter((t,r,e)=>e.indexOf(t)===r)}function l(t){return!Array.isArray(t)||t.length<1?null:t.reduce((t,r)=>t+r,0)}function f(t){return!Array.isArray(t)||t.length<1?null:l(t)/t.length}function p(t){const r=t.length;return t[Math.floor(Math.random()*(r-0))+0]}function y(t,r,e){const n=r.split(".");let i=t;for(;n.length>0;){const t=n.shift();if(null==i||!Object.prototype.hasOwnProperty.call(i,t))return e;i=i[t]}return i}function d(t){return!Array.isArray(t)||t.length<1?null:t[0]}function g(t){return!Array.isArray(t)||t.length<1?null:t[t.length-1]}class A extends Array{static get[Symbol.species](){return Array}multisort(t,e){return r(this[0],t,e)}multifilter(t,r,e){return s(this[0],t,r,e)}multikey(t){return h(this[0],t)}intersect(t,r){return o(this[0],t,r)}diff(t,r){return c(this[0],t,r)}get unique(){return a(this[0])}pushIfNotExists(t){return this.indexOf(t)<0&&this.push(t),this.length}pushMultiple(t){return this.push(...t),this.length}pushMultipleIfNotExists(t){const r=this;return t.forEach(t=>{r.pushIfNotExists(t)}),r.length}get max(){return n(this[0])}get min(){return e(this[0])}get random(){return p(this)}get summ(){return l(this[0])}get average(){return f(this[0])}getByKey(t,r){return y(this[0],t,r)}get first(){return d(this[0])}get last(){return g(this[0])}}export{A as Arr,f as average,c as diff,d as first,y as getByKey,o as intersect,g as last,n as max,e as min,s as multifilter,h as multikey,r as multisort,p as random,l as summ,a as unique};
2
//# sourceMappingURL=helpers.modern.js.map
3